Imports MbUnit.Framework
Imports QS = AppliedRecognition.Speech.QuickSwitch
Imports System.ComponentModel

'<TestFixture("Test licensing")> _
Public Class LicenseTest

    Dim d As QS.CommandDispatch
    Dim rw As QS.ResizePreviewForm
    Dim u As New Util

    '<ExpectedException(GetType(LicenseException))> _
    'Sub NoLicTest()
    '        u.WriteConfigFileToDir("DevNone.lic", Environment.CurrentDirectory, "license.lic")
    '    d = New QS.CommandDispatch
    'End Sub

    <Test()> _
    Sub BasicOnBasicLic()
        u.WriteConfigFileToDir("DevBasic.lic", Environment.CurrentDirectory, "license.lic")
        d = New QS.CommandDispatch
    End Sub

    <Test()> _
    Sub CompleteOnBasicLic()
        u.WriteConfigFileToDir("DevComplete.lic", Environment.CurrentDirectory, "license.lic")
        d = New QS.CommandDispatch
    End Sub

    <Test(), ExpectedException(GetType(LicenseException))> _
    Sub BasicLicFailOnCompleteFeature()
        u.WriteConfigFileToDir("DevBasic.lic", Environment.CurrentDirectory, "license.lic")
        d = New QS.CommandDispatch
        rw = QS.ResizePreviewForm.Instance

    End Sub

    <Test(), Ignore("sdf")> _
    Sub CompleteLicOnCompleteFeature()
        u.WriteConfigFileToDir("DevComplete.lic", Environment.CurrentDirectory, "license.lic")
        d = New QS.CommandDispatch
        rw = QS.ResizePreviewForm.Instance
    End Sub



    <SetUp()> _
    Sub SetUp()
        Dim licf() As String = IO.Directory.GetFiles(Environment.CurrentDirectory, "*.lic")
        For Each f As String In licf
            IO.File.Delete(f)
        Next
        If Not d Is Nothing Then
            d.Dispose()
            d = Nothing
        End If
    End Sub

    <TearDown()> _
    Sub TearDown()
        If QS.CommandDispatch.Exists Then
            QS.CommandDispatch.DefaultInstance.Dispose()
        End If
        'rw = Nothing
        'If QS.ResizePreviewForm.Exists Then
        '    QS.ResizePreviewForm.Instance.Close()
        'End If
    End Sub

End Class
